package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: RequestDemo05
 * @Description:
 * @author: RZS
 * @date: 2022/4/11  15:29
 */
@WebServlet("/rd5.do")
public class RequestDemo05 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 处理Demo04转发过来的请求
        // 响应内容
        response.setContentType("text/html;charset=utf-8");
        PrintWriter writer = response.getWriter();
        writer.println("<h1>转发到了RquestDemo05</h1>");

        // 获取请求域绑定的数据
        String name = (String) request.getAttribute("name");
        String desc = (String) request.getAttribute("desc");

        writer.println("<h1>"+ name + desc +"</h1>");
        writer.close();
    }
}
